package com.pmcc.yn.web;

import com.pmcc.utils.AntdPage;
import com.pmcc.utils.ResultBean;
import com.pmcc.yn.entity.OrderList;
import com.pmcc.yn.service.StoreInfoService;
import com.pmcc.yn.service.TechnicianInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * @author yaonan 2019/1/15
 */
@RestController()
@RequestMapping("api/v2/base")
@Api(value = "BaseJsController" , description = "小程序的技师端接口")
public class BaseJsController {


    @Autowired
    StoreInfoService storeInfoService;
    @Autowired
    TechnicianInfoService technicianInfoService;


    @ApiOperation(value = "技师登录合并注册操作", httpMethod = "POST", notes = "传入wxid", response = ResultBean.class)
    @PostMapping(value = "jslogin")
    public ResultBean jslogin(String wxid){
        /**
         * 移动端传入wxid，先判断在该wxid是否在技师表中存在，如果存在则允许登录，返回该技师的基本信息，
         * 如果不存在则新增一条记录。同样返回技师的基本信息
         *
         */
        return technicianInfoService.jslogin(wxid);
    }
    //补充技师信息 徐婉琳


    @ApiOperation(value = "门店登录合并注册操作", httpMethod = "POST", notes = "传入wxid", response = ResultBean.class)
    @PostMapping(value = "login")
    public ResultBean login( String wxid){
        /**
         * 移动端传入wxid，先判断在该wxid是否在门店表中存在，如果存在则允许登录，返回门店的id和已经门店的基本信息，
         * 如果不存在则新增一条门店记录。同样返回门店的基本信息，在resultDesc里面要求填写是新创建的门店
         *
         */
        return technicianInfoService.login(wxid);
    }

//    @ApiOperation(value = "门店订单列表信息展示", httpMethod = "POST", notes = "传入门店id", response = ResultBean.class)
//    @PostMapping(value = "marketOrder")
//    public ResultBean marketOrder(AntdPage antdPage, String id){
//        /**
//         * 传入门店的id，默认筛选出门店的最近的10条订单，按照传入的分页参数来控制返回的订单条目，订单按照时间倒叙排列
//         * 订单列表的list放在rows里面，订单的返回数据有，订单的id，订单的门店名称，贴膜时间，所在地，任务状态，订单金额，报名人数
//         *
//         */
//        return oderListService.marketOrder(antdPage,id);
//    }
    @ApiOperation(value = "门店订单列表详情展示", httpMethod = "POST", notes = "传入订单id", response = ResultBean.class)
    @PostMapping(value = "orderDetail")
    public ResultBean orderDetail(String id){
        /**
         * 传入订单的id,返回该订单信息，订单的id，所在门店，所在地，X坐标，Y坐标，贴膜时间，订单金额，任务状态，车型，服务类型，门店id
         *
         */
        return null;
    }
//    @ApiOperation(value = "新增订单", httpMethod = "POST", notes = "传入订单的实体对象", response = ResultBean.class)
//    @PostMapping(value = "addOrder")
//    public ResultBean addOrder(OrderList model){
//        /**
//         * 传入订单订单的实体对象，实体里面包含成员：贴膜时间，车型，服务类型，门店id，订单要求，赏金，
//         *
//         */
//        return oderListService.add(model);
//    }
    @ApiOperation(value = "补充门店信息", httpMethod = "POST", notes = "传入门店的基本信息", response = ResultBean.class)
    @PostMapping(value = "supplement")
    public ResultBean supplement(Map map){
        /**
         * 传入门店的名称，门店的电话，门店的坐标，门店的具体地址，省市区，负责人名称
         *
         */
        return storeInfoService.update(map);
    }
    @ApiOperation(value = "补充门店照片信息", httpMethod = "POST", notes = "传入门店的照片", response = ResultBean.class)
    @PostMapping(value = "supplementPhoto")
    public ResultBean supplementPhoto(@RequestParam("file") MultipartFile file,String mid,String type){
        /**
         * 传入门店的id即mid，传入照片的类型，即身份证正面，反面，门头照片，店内照片，
         *
         *
         */
        return storeInfoService.supplementPhoto(file,mid,type);
    }
    @ApiOperation(value = "取消订单", httpMethod = "POST", notes = "传入门店id，订单id", response = ResultBean.class)
    @PostMapping(value = "cancelOrder")
    public ResultBean cancelOrder(String mid,String orderid){
        /**
         * 传入门店id，订单id，修改订单的状态
         *
         *
         */
        return null;
    }
    @ApiOperation(value = "显示订单的报名信息", httpMethod = "POST", notes = "订单id", response = ResultBean.class)
    @PostMapping(value = "personList")
    public ResultBean personList(String orderid){
        /**
         * 传入订单id，查询报名的技师列表，技师按照评分进行排序
         *
         *
         */
        return null;
    }
    @ApiOperation(value = "查看技师详细信息", httpMethod = "POST", notes = "技师id", response = ResultBean.class)
    @PostMapping(value = "findById")
    public ResultBean findById(String id){
        /**
         * 传入技师ID，查询技师的相关信息，object查询技师的基本资料信息，rows放置技师历史接单信息
         *
         *
         */
        return null;
    }
    @ApiOperation(value = "选择技师", httpMethod = "POST", notes = "技师id,订单id", response = ResultBean.class)
    @PostMapping(value = "updateById")
    public ResultBean updateById(String id,String orderId){
        /**
         * 传入技师ID，订单id，修改订单的状态，确认该订单由该技师来执行
         *
         *
         */
        return null;
    }
    @ApiOperation(value = "追加赏金", httpMethod = "POST", notes = "订单id,追加金额", response = ResultBean.class)
    @PostMapping(value = "updateMoneyById")
    public ResultBean updateMoneyById(String id,String money){
        /**
         * 传入订单id，追加金额，修改订单的金额信息
         *
         *
         */
        return null;
    }
    @ApiOperation(value = "门店评分", httpMethod = "POST", notes = "订单id，评分，评价", response = ResultBean.class)
    @PostMapping(value = "score")
    public ResultBean score(String id,String score,String assess){
        /**
         * 传入订单id，评分，评价，增加改技师的评分记录（记住回写技师的总评分）
         *
         *
         */
        return null;
    }
    @ApiOperation(value = "评分照片上传", httpMethod = "POST", notes = "订单id", response = ResultBean.class)
    @PostMapping(value = "scorePhoto")
    public ResultBean scorePhoto(@RequestParam("file") MultipartFile file,String id){
        /**
         * 传入订单id，照片，写入照片附件表
         *
         *
         */
        return null;
    }

//    /**
//     *技师的个人信息展示
//     * @param id 技师id
//     * @return 技师的详细信息
//     */
//    @ApiOperation(value = "技师的个人信息展示", httpMethod = "POST", notes = "传入技师的id，得到技师的个人信息", response = ResultBean.class)
//    @PostMapping(value = "getTechInfo")
//    public ResultBean getTechInfo(String id){
//        /**
//         * 传入技师的id，得到该技师的详细信息
//         *
//         */
//        return technicianInfoService.findById(id);
//    }



}
